package top.bug.blog.controller.backend;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.bug.blog.annotation.Auth;
import top.bug.blog.common.Result;
import top.bug.blog.entity.dto.common.BatchRequest;
import top.bug.blog.entity.po.SensitiveWord;
import top.bug.blog.service.SensitiveWordFilterService;

import javax.annotation.Resource;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 后台-敏感词管理模块
 */
@Api(tags = "敏感词管理模块")
@RestController
@RequestMapping("/sensitiveWordApi")
@Auth
public class SensitiveWordController {
    @Resource
    private SensitiveWordFilterService sensitiveWordFilterService;

    @PostMapping("/getList")
    @ApiOperation("获取列表")
    public Result<Page<SensitiveWord>> getList(@RequestBody SensitiveWord queryRequest) {
        return Result.success(sensitiveWordFilterService.getList(queryRequest));
    }

    @PostMapping("/add")
    @ApiOperation("新增数据")
    public Result<Boolean> add(@RequestBody SensitiveWord addRequest) {
        return Result.success(sensitiveWordFilterService.add(addRequest));
    }

    @PostMapping("/edit")
    @ApiOperation("更新数据")
    public Result<Boolean> edit(@RequestBody SensitiveWord updateRequest) {
        return Result.success(sensitiveWordFilterService.edit(updateRequest));
    }

    @PostMapping("/delete")
    @ApiOperation("批量删除数据")
    public Result<Boolean> delete(@RequestBody BatchRequest batchRequest) {
        return Result.success(sensitiveWordFilterService.delete(batchRequest));
    }

}